$(function () {
    /*
    // Пример рабочей гриды
    $("#grid").jqGrid({
        url: basic_path + "/core/login/asd",
        datatype: "json",
        mtype: "GET",
        colNames: ["Inv No", "Date", "Amount", "Tax", "Total", "Notes+"],
        colModel: [
            { name: "invid", width: 55 },
            { name: "invdate", width: 90 },
            { name: "amount", width: 80, align: "right" },
            { name: "tax", width: 80, align: "right" },
            { name: "total", width: 80, align: "right" },
            { name: "note", width: 150, sortable: false }
        ],
        pager: "#pager",
        rowNum: 10,
        rowList: [1, 20, 300],
        sortname: "invid",
        sortorder: "desc",
        viewrecords: true,
        gridview: true,
        autoencode: true,
        caption: "My first grid",
        width: 660
    });
    */
});



function deleteItem( entity, id, grid_unit,unit ){

    $.post(basic_path + "/core/dbapi/delete", {
        entity:entity,
        id : id,
        unit: unit
    }, function (responceobj, status) {

        if (status == 'success') {
            if(responceobj.responcestatus == 'ok'){
                jQuery("#" + grid_unit + "_grid").trigger('reloadGrid');
                jQuery("#" + grid_unit + "_grid").trigger('reloadGrid');
            }

        } else {
            //ActionDialog("Cant pick products", "alert");
        }
    }, 'json');

}

function toggleVisibility( entity, id, grid_unit,unit ){

    $.post(basic_path + "/core/dbapi/togglephotovisibility", {
        entity:entity,
        id : id,
        unit: unit
    }, function (responceobj, status) {

        if (status == 'success') {
            if(responceobj.responcestatus == 'ok'){
                jQuery("#" + grid_unit + "_grid").trigger('reloadGrid');
                jQuery("#" + grid_unit + "_grid").trigger('reloadGrid');
            }

        } else {
            //ActionDialog("Cant pick products", "alert");
        }
    }, 'json');

}
